package admincow.servlet.funcion;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import admincow.dao.FuncionDAO;
import admincow.vo.FuncionVO;




public class FuncionBuscarServlet extends javax.servlet.http.HttpServlet
		implements javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	public FuncionBuscarServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		System.out.println("FuncionBuscarServlet");
		String x = request.getParameter("funcion");
		FuncionDAO dao = new FuncionDAO();
		Collection<FuncionVO> y = dao.buscarPorNombre(x); 

		// Guardar arreglo en ambiente request
		//request.setAttribute("arreglo", y);
		request.setAttribute("arreglo", y);

		// Hacer forward a jsp (cooperacion)
		RequestDispatcher rd = request
				.getRequestDispatcher("/funcionBuscar.jsp");
		rd.forward(request, response);

	}

}